"use strict";
/**
 *
 * @param  {Array} userRouter 后台返回的用户权限json
 * @param  {Array} allRouter  前端配置好的所有动态路由的集合
 * @return {Array} realRoutes 过滤后的路由
 */
exports.__esModule = true;
exports.setDefaultRoute = exports.recursionRouter = void 0;
function recursionRouter(userRouter, allRouter) {
    if (userRouter === void 0) { userRouter = []; }
    if (allRouter === void 0) { allRouter = []; }
    // console.log(userRouter,allRouter,1)
    var realRoutes = [];
    allRouter.forEach(function (v, i) {
        userRouter.forEach(function (item, index) {
            //根据type进行对比
            if (item.type === v.type) {
                if (item.children && item.children.length > 0) {
                    v.children = recursionRouter(item.children, v.children);
                }
                realRoutes.push(v);
            }
        });
    });
    // console.log(realRoutes,2)
    return realRoutes;
}
exports.recursionRouter = recursionRouter;
/**
 *
 * @param {Array} routes 用户过滤后的路由
 *
 * 递归为所有有子路由的路由设置第一个children.path为默认路由
 */
function setDefaultRoute(routes) {
    routes.forEach(function (v, i) {
        if (v.children && v.children.length > 0) {
            v.redirect = { name: v.children[0].name };
            setDefaultRoute(v.children);
        }
    });
}
exports.setDefaultRoute = setDefaultRoute;
